package com.fadadianqi.goods.dao.ibatis;


import com.fadadianqi.commons.GenericDAOSuport;
import com.fadadianqi.goods.dao.GoodsPropValueDAO;
import com.fadadianqi.goods.model.GoodsPropValue;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class GoodsPropValueDAOImpl extends
        GenericDAOSuport<String, GoodsPropValue> implements GoodsPropValueDAO {

    @Override
    protected Class<?> getObjectClass() {
        return GoodsPropValue.class;
    }

    @Override
    protected String getTableName() {
        return "goods_properties_value";
    }

    @Override
    public GoodsPropValue getByGoodsIdAndValId(String goodsId, String valId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("goodsId", goodsId);
        map.put("propValueId", valId);
        return super.getByPropertys(map);
    }

    @Override
    public List<GoodsPropValue> findByGoodsId(String goodsId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("goodsId", goodsId);
        return super.findByPropertys(map);
    }

    @Override
    public void removeByGoodsId(String goodsId) {
        getSqlMapClientTemplate().delete(getNamespace() + ".removeByGoodsId", goodsId);
    }

}
